package com.example.blog.controller.blog;

import com.example.blog.pojo.Reply;
import com.example.blog.pojo.Result;
import com.example.blog.service.ReplyService;
import com.example.blog.util.TokenUtil.GetCookie;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/Replies")
public class ReplyController {
    @Resource
    private ReplyService replyService;
    //添加评论
    @PostMapping("/addReply/{commentId}")
    public Result saveReplyComment(@RequestBody Reply reply,@RequestParam String text, @PathVariable int commentId, HttpServletRequest request){
        String cookieValue = request.getHeader("Cookie");
        String token = GetCookie.getCookieValue(cookieValue);
        return replyService.saveReplyComment(reply,text,commentId,token);
    }
    //回复评论
    @GetMapping("/getReply/{commentId}")
    public Result getReplyComment(@PathVariable int commentId){
        return replyService.getReplyComment(commentId);
    }

}
